home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / rbbs_pc / mapl0301.zip / ANSIED.MRG < prev    next >
Text File  |  1993-03-01  |  49KB  |  1,277 lines

  1. * ------------[ BLED merge (c) Ken Goosens ]-------------
  2. * Merge this against E:\RBBS\STOCK\ANSIED.BAS to produce E:\RBBS\CHAT\ANSIED.BAS
  3. * E:\RBBS\STOCK\ANSIED.BAS:  Date 2-16-1991  Size 43992 bytes
  4. * ------------[ Created 03-01-1993 19:16:00 ]------------
  5. * REPLACING old line(s) by new
  6. * ------[ first line different ]------
  7. ' $linesize:132
  8. ' $title: 'ANSIED.BAS'
  9. '*
  10. '*  ANSIED v2.44a  by Tom Collins 
  11. '*---------------------------------------------------------------------------
  12. '*  Full Screen Text Editor for RBBS-PC
  13. '*  QuickBASIC v4.5 Version
  14. '*  02-16-91
  15. '*
  16. '*  v2.1xx ... made it work with RBBS v17
  17. '*  v2.2 ..... fixed some inconsistincies in the code as to # of lines in msg.
  18. '*             Some of the code thought 99 was length, some thought 100.
  19. '*  v2.3 ..... let it work with quoted reply.  No more REDIM of ZOutTxt$
  20. '*  v2.4 ..... removed tabs, margins code to be smaller
  21. '*  v2.41..... fixed bug with loss of bold attribute occasionally
  22. '*  v2.42..... made it work as a v17.3 subroutine.  Added block delete.
  23. '*  v2.43..... Added to: and from:.  Made cursor keys work locally.
  24. '*  v2.43a.... Stupid little bugs fixed
  25. '*  v2.44..... Fixed bugs, added ^T, Import, Subject, ASM functions
  26. '*  v2.44a.... Wordwrap/reflow bug fixed.  Arrows work in del.  Lines renum.
  27. '*
  28. '*  Returns:
  29. '*  ZSubParm  =  1 - Save Message
  30. '*            =  2 - Abort Message
  31. '*            = -1 - Dropped Carrier
  32. '*            = -2 - Sleep Disconnect
  33. '*
  34. '* Compile with:
  35. '*   BC C:\RBBSARCS\ANSIED.BAS /O/T/C:512;
  36. '*
  37. '* Modifications to 2.44a by: Steve Stevens
  38. '* If you Like 'em let me know!
  39. '*       FIDONET 1:376/102                      RBBSNet 8:927/2
  40.  
  41. ' $INCLUDE: 'RBBS-VAR.MOD'
  42.  
  43. * REPLACING old line(s) by new
  44. 110   CONST ESCKey = 27
  45.       CONST BackspKey = 8
  46.       CONST OtherBackspKey = 127
  47.       CONST CarrRet = 13
  48.       CONST WordLeftKey = 1          ' Ctrl-A
  49.       CONST ReformTextKey = 2        ' Ctrl-B
  50.       CONST PageDownKey = 3          ' Ctrl-C
  51.       CONST ColRightKey = 4          ' Ctrl-D
  52.       CONST LineUpKey = 5            ' Ctrl-E
  53.       CONST WordRightKey = 6         ' Ctrl-F
  54.       CONST CharDeleteKey = 7        ' Ctrl-G
  55. * ------[ first line different ]------
  56.       CONST TabKey = 9               ' Ctrl-I <- Tab Key Support
  57.       CONST HelpExpertKey = 10       ' Ctrl-J <- Turn Help Screen OFF 'Mpl021702
  58.       CONST EndSessionKey = 11       ' Ctrl-K
  59.       CONST HelpKey = 14             ' Ctrl-N
  60.       CONST ReflowTextKey = 15       ' Ctrl-O
  61.       CONST RepaintKey = 16          ' Ctrl-P
  62.       CONST PageUpKey = 18           ' Ctrl-R
  63.       CONST ColLeftKey = 19          ' Ctrl-S
  64.       CONST DeleteWordRightKey = 20  ' Ctrl-T
  65.       CONST ToggleINSKey = 22        ' Ctrl-V
  66.       CONST HomeKey = 23             ' Ctrl-W
  67.       CONST LineDownKey = 24         ' Ctrl-X
  68.       CONST LineDeleteKey = 25       ' Ctrl-Y
  69.       CONST EndKey = 26              ' Ctrl-Z
  70.  
  71.       CONST BlankLine$ = ""
  72. * REPLACING old line(s) by new
  73. 120   COMMON SHARED /Ansied/ CurrentRow, CurrentCol, TopLine
  74.       COMMON SHARED /Ansied/ OldColour, IsBold, InsertMode
  75.       COMMON SHARED /Ansied/ SoftSpace$
  76.       COMMON SHARED /Ansied/ BlockDelActive, MsgLockLines
  77.       COMMON SHARED /Ansied/ BlockLine1, BlockLine2
  78.       COMMON SHARED /Ansied/ MsgTo$, MsgSubj$
  79.  
  80. '*  AnsiEd
  81. '*----------------------------------------------------------------------------
  82. '*  Main full-screen editor routine
  83. '*
  84. '*
  85. * ------[ first line different ]------
  86.       SUB Ansied (T$, S$, L%)  Static
  87.       '*
  88.       '* ZworkAra$() holds what's currently on the user's screen.
  89.       '* 24 Lines: ZWorkAra$(1) = Menu, Bottom Line = "Line 25"
  90.       '*
  91.  
  92. * REPLACING old line(s) by new
  93. 500   REDIM ZWorkAra$(24)
  94.       '*
  95.       '* TopLine is the index into the ZOutTxt$() array that
  96.       '* corresponds to the top of the displayed image, i.e.
  97.       '* what's on line 3 of the user's screen.
  98.       '*
  99.       '*   1,12,23,34,45,56,78
  100.       '*
  101. * ------[ first line different ]------
  102.       SaveExpertUser = ZExpertUser                                   ' DD021702
  103.       TopLine = 1
  104.       SoftSpace$ = CHR$(250)
  105.       InsertMode = ZTrue
  106.       ZLineFeed$ = CHR$(10)
  107.       BlockDelActive = ZFalse
  108.       HiLiteSave = ZHiLiteOff
  109.       ZHiLiteOff = ZFalse
  110.       UseTputSave = ZUseTput
  111.       ZUseTput = ZFalse
  112.       MsgLockLines = L%
  113.       MsgTo$ = T$
  114.       CALL NameCaps(MsgTo$)
  115.  
  116.       MsgSubj$ = S$
  117.       YY$ = ""
  118.       IF LEFT$(MsgSubj$, 3) = "(R)" THEN
  119.          YY$ = "(R)"
  120.          MsgSubj$ = MID$(MsgSubj$, 4)
  121.       END IF
  122.       CALL NameCaps(MsgSubj$)
  123.       MsgSubj$ = YY$ + MsgSubj$
  124.  
  125.       '*
  126.       '* Initialize the screen
  127.       '*
  128. * REPLACING old line(s) by new
  129. 510   CALL ClearScreen
  130.       CALL UpdateStatusLine(1)
  131. * ------[ first line different ]------
  132.       CALL DisplayKeys
  133.       CALL MoveCursor(3, 1)
  134.       '*
  135.       '* Remove ANSI sequences from the quoted lines
  136.       '*
  137.       IF ZLinesInMsg > (ZMsgDim - 11) THEN                           ' DD021702
  138.          ZLinesInMsg = (ZMsgDim - 11)                                ' DD021702
  139.       END IF
  140.       IF ZMaxMsgLines > (ZMsgDim - 1) THEN                           ' DD021702
  141.          ZMaxMsgLines = (ZMsgDim - 1)                                ' DD021702
  142.       END IF
  143.       IF ZLinesInMsg > ZMaxMsgLines THEN
  144.          ZLinesInMsg = ZMaxMsgLines
  145.       END IF
  146.       FOR I = ZLinesInMsg + 1 TO ZMaxMsgLines                        ' DD021702
  147.          ZOutTxt$(I) = BlankLine$
  148.       NEXT
  149.       IF ZLinesInMsg <> 0 THEN
  150.          FOR I = 1 TO ZLinesInMsg
  151.             CALL UnString(ZOutTxt$(I), CHR$(27) + CHR$(91))          ' DD021301
  152.          NEXT
  153.          J = ZLinesInMsg \ 11
  154.          IF ZLinesInMsg MOD 11 = 0 THEN
  155.            J = J - 1
  156.          END IF
  157.          TopLine = J * 11 + 1
  158.          J = ZLinesInMsg - TopLine
  159.          CALL MoveCursor(J + 5, 1)
  160.       END IF
  161.       CALL UpdateScreen
  162.       '*
  163.       '* Run the Editor
  164.       '*
  165. * REPLACING old line(s) by new
  166. 525      IF KeyPressed = ESCKey THEN            ' v2.44a
  167.             CALL GetChar(B$): GOSUB 740
  168. * ------[ first line different ]------
  169.             IF B$ = CHR$(91) THEN                    ' ANSI sequence ' DD021301
  170.                CALL GetChar(B$): GOSUB 740
  171.                IF B$ = CHR$(67) THEN                            'C   ' DD021301
  172.                   KeyPressed = ColRightKey
  173.                ELSEIF B$ = CHR$(68) THEN                        'D   ' DD021301
  174.                   KeyPressed = ColLeftKey
  175.                ELSEIF B$ = CHR$(65) THEN                        'A   ' DD021301
  176.                   KeyPressed = LineUpKey
  177.                ELSEIF B$ = CHR$(66) THEN                        'B   ' DD021301
  178.                   KeyPressed = LineDownKey
  179.                END IF
  180.             END IF
  181.          END IF
  182.  
  183.          Index = CurrentRow + TopLine - 3
  184.  
  185.          IF BlockDelActive OR Index <= MsgLockLines OR Index > ZMaxMsgLines THEN
  186. * REPLACING old line(s) by new
  187. 530         SELECT CASE KeyPressed
  188.                CASE CarrRet
  189.                   IF BlockDelActive THEN
  190.                      BlockDelActive = ZFalse
  191.                      BlockLine2 = Index
  192.                      IF BlockLine2 < BlockLine1 THEN
  193.                         SWAP BlockLine1, BlockLine2
  194.                      END IF
  195.                      IF BlockLine1 <= MsgLockLines THEN
  196.                         BlockLine1 = MsgLockLines + 1
  197.                      END IF
  198.                      IF BlockLine2 > ZMaxMsgLines THEN
  199.                         BlockLine2 = ZMaxMsgLines
  200.                      END IF
  201.                      K = 0
  202. * ------[ first line different ]------
  203.                      FOR I = BlockLine2 + 1 TO ZMsgDim               ' DD021702
  204.                         ZOutTxt$(BlockLine1 + K) = ZOutTxt$(I)
  205.                         K = K + 1
  206.                      NEXT I
  207.                      WHILE BlockLine1 + K <= ZMsgDim                 ' DD021702
  208.                         ZOutTxt$(BlockLine1 + K) = BlankLine$
  209.                         K = K + 1
  210.                      WEND
  211.                      CALL UpdateScreen
  212.                      CALL UpdateStatusLine(1)     'Pe 021993
  213.                      CALL MoveCursor(BlockRow, BlockCol)
  214.                   END IF
  215.                   KeyPressed = 255
  216.  
  217. * REPLACING old line(s) by new
  218. 540            CASE ESCKey
  219.                   IF BlockDelActive THEN
  220.                      BlockDelActive = ZFalse
  221. * ------[ first line different ]------
  222.                      CALL ClearScreen        ' <-- Added when user cancells  'Mpl021701
  223.                      CALL UpdateScreen       ' Block Delete the "highlighted"'Mpl021701
  224.                      CALL UpdateStatusLine(1)                        'Mpl021701
  225. '                    CALL UpdateStatusLine(2)                        'Mpl021701
  226.                      CALL DisplayKeys                                ' DD021702
  227.                      CALL MoveCursor(BlockRow, BlockCol)
  228.                      KeyPressed = 255
  229.                   END IF
  230.  
  231.                CASE LineUpKey                                        ' DD021702
  232.                   CALL SaveCursor(SaveRow, SaveCol)                  ' DD021702
  233.                   CALL MoveCursor(CurrentRow,1)                      ' DD021702
  234.                   IF CurrentRow > 3 THEN                             ' DD021301
  235.                      CALL Putscreen(ZOutTxt$(Index), YellowFore,ZTrue)' DD021702
  236.                   END IF                                             ' DD021301
  237.                   CALL MoveCursor(SaveRow, SaveCol)                  ' DD021702
  238.  
  239.                CASE LineDownKey                                      ' DD021702
  240.                   CALL SaveCursor(SaveRow, SaveCol)                  ' DD021702
  241.                   CALL MoveCursor(CurrentRow,1)                      ' DD021702
  242.                   CALL Putscreen(ZOutTxt$(Index), RedFore,ZFalse)    ' DD021702
  243.                   IF ZExpertUser THEN PE = 23 _
  244.                      Else PE = 19
  245.                   IF CurrentRow + 1 < PE THEN
  246.                      CALL MoveCursor(CurrentRow+1,1)
  247.                      CALL Putscreen(ZOutTxt$(Index+1), RedFore,ZFalse)
  248.                   END IF
  249.                   CALL MoveCursor(SaveRow, SaveCol)                  ' DD021702
  250.  
  251.                CASE PageDownKey, PageUpKey                           ' DD021301
  252.                   '*
  253.                   '* Up and Down get passed on
  254.                   '*
  255.                CASE ELSE
  256.                   '*
  257.                   '* Ignore the key
  258.                   '*
  259.                   KeyPressed = 255
  260.  
  261.             END SELECT
  262.          END IF
  263.  
  264. * REPLACING old line(s) by new
  265. 560      SELECT CASE KeyPressed
  266. * ------[ first line different ]------
  267.             CASE ESCKey, EndSessionKey                               'Pe 03/17/92
  268.                '*
  269.                '* User wants to see main menu
  270.                '*
  271.                CALL DisplayMainMenu
  272.                CALL MoveCursor(RowSave, ColSave)
  273.                CALL GetChar(B$): GOSUB 740
  274.                CALL AllCaps(B$)                                      'RT062992
  275.                IF B$ = CHR$(68) THEN                            'D   ' DD021301
  276.                   BlockDelActive = ZTrue
  277.                   BlockLine1 = RowSave + TopLine - 3
  278.                   BlockCol = ColSave
  279.                   BlockRow = RowSave
  280.                   CALL EraseToEOL(1, 1)                  ' v2.44a
  281.                   CALL PutScreen("Delete Block: Press ENTER on Last Line to Delete, or ESC Twice to Quit", DefaultColor, DefaultBold)
  282.                   BlockLine2 = 0
  283.                   CALL MoveCursor(RowSave, 1)                        'SM070501
  284.                   Index = (RowSave) + (Topline - 3)                  'Mpl021701
  285.                   CALL Putscreen(ZOutTxt$(Index),RedFore,ZFalse)     'Mpl021701
  286.                ELSE
  287.                   CALL MenuCommand(B$): GOSUB 740
  288.                END IF
  289.                CALL MoveCursor(RowSave, ColSave)
  290.  
  291. * REPLACING old line(s) by new
  292. 570         CASE LineUpKey
  293.                '*
  294.                '* Move the current cursor position up one line
  295.                '*
  296.                IF CurrentRow > 3 THEN
  297.                   CALL MoveCursor(CurrentRow - 1, CurrentCol)
  298.                ELSE
  299.                   IF TopLine <> 1 THEN
  300.                      TopLine = TopLine - 11
  301. * ------[ first line different ]------
  302.                      IF TopLine < 1 THEN                             ' DD021702
  303.                         TopLine = 1                                  ' DD021702
  304.                      ENDIF                                           ' DD021702
  305.                      CALL MoveCursor(CurrentRow + 10, CurrentCol)
  306.                      CALL UpdateScreen
  307.                   END IF
  308.                END IF
  309.  
  310. * REPLACING old line(s) by new
  311. 580         CASE LineDownKey
  312.                '*
  313.                '* Move the current cursor position down one line
  314.                '*
  315. * ------[ first line different ]------
  316.                IF ZExpertUser THEN PE = 23 _                         'Mpl021701
  317.                   Else PE = 19                                       'Mpl021701
  318.                IF CurrentRow < PE THEN                               'Mpl021701
  319.                   IF (CurrentRow + (TopLine - 3)) < ZMaxMsgLines THEN
  320.                      CALL MoveCursor(CurrentRow + 1, CurrentCol)
  321.                   END IF
  322.                ELSEIF BlockDelActive THEN                            'Mpl021701
  323.                   CALL PutScreen(CHR$(7),RedFore,ZFalse)             'Mpl021701
  324.                   CALL MoveCursor(CurrentRow,1)                      ' DD021702
  325.                ELSE
  326.                   IF TopLine < ZMaxMsgLines - 10 THEN
  327.                      TopLine = TopLine + 11
  328.                      CALL MoveCursor(CurrentRow - 10, CurrentCol)
  329.                      CALL UpdateScreen
  330.                   END IF
  331.                END IF
  332.  
  333. * INSERTING new line(s)
  334. 595         CASE TabKey    ' <- Tab Key Support here..
  335.                '*
  336.                '* Tab 8 Spaces
  337.                '*
  338.                IF CurrentCol < 72 THEN
  339.                 CALL MoveCursor(CurrentRow, CurrentCol + 8)
  340.                END IF
  341.  
  342. * REPLACING old line(s) by new
  343. 650         CASE PageDownKey
  344.                '*
  345.                '* Move the display one page down
  346.                '*
  347.                TopLine = TopLine + 22
  348. * ------[ first line different ]------
  349.                IF TopLine > ZMaxMsgLines - 15 THEN                   ' DD021702
  350.                   TopLine = ZMaxMsgLines - 15                        ' DD021702
  351.                END IF
  352.                CALL UpdateScreen
  353.  
  354. * REPLACING old line(s) by new
  355. * ------[ first line different ]------
  356. 710         CASE HelpKey,HelpExpertKey,ReformTextKey, ReflowTextKey, ToggleINSKey, RepaintKey 'Mpl021701
  357.                '*
  358.                '* Execute a main menu command
  359.                '*
  360.                '*          1234567890123456789012
  361.  
  362.  
  363.                IF KeyPressed = HelpExpertKey THEN
  364.                   ZExpertUser = ZTrue
  365.                END IF
  366.                IF KeyPressed = HelpKey THEN
  367.                   ZExpertUser = ZFalse
  368.                END IF
  369.  
  370.  
  371.                YY$ = MID$(" J       N   HRP     I", KeyPressed, 1)
  372.                CALL MenuCommand(YY$): GOSUB 740
  373.                CALL MoveCursor(RowSave, ColSave)
  374.  
  375.             CASE IS > 127, IS < 32
  376.                '*
  377.                '* Ignore characters above 127 or below 32
  378.                '*
  379. * REPLACING old line(s) by new
  380. * ------[ first line different ]------
  381. 730   REDIM ZWorkAra$(ZMsgDim)
  382.       REDIM Places(1)                                                ' DD021702
  383.       ZHiLiteOff = HiLiteSave
  384.       ZUseTput = UseTputSave
  385.       S$ = MsgSubj$                                                  'RT062992
  386.       CALL AllCaps(S$)                                               'RT062992
  387.       ZExpertUser = SaveExpertUser                                   ' DD021702
  388.       EXIT SUB
  389.  
  390.       '*
  391.       '* Test ZSubParm and Exit ANSIED if the carrier dropped
  392.       '*
  393. * REPLACING old line(s) by new
  394. 740   IF ZSubParm <> 0 THEN
  395.          GOTO 730
  396.       END IF
  397.       RETURN
  398.  
  399.       END SUB         ' Sub AnsiEd
  400.  
  401. '*  BackspChar()
  402. '*----------------------------------------------------------------------------
  403. '*  This routine handles the user entering the backspace key
  404. '*
  405. '*
  406. * ------[ first line different ]------
  407.       SUB BackspChar  Static
  408. * REPLACING old line(s) by new
  409. 1230     ELSE
  410.             CALL FindWrap(LEFT$(ZOutTxt$(Index - 1), ZRightMargin + 1), I)
  411.             IF I <= 1 THEN
  412.                I = ZRightMargin
  413.             END IF
  414.             ZOutTxt$(Index) = MID$(ZOutTxt$(Index - 1), I + 1)
  415.             ZOutTxt$(Index - 1) = LEFT$(ZOutTxt$(Index - 1), I)
  416.          END IF
  417.          IF RowSave > 3 THEN
  418.             CALL MoveCursor(RowSave - 1, NewCol)
  419.             CALL UpdateScreen
  420.          ELSE
  421.             CALL MoveCursor(RowSave, NewCol)
  422.             CALL UnGetChar(LineUpKey)
  423.          END IF
  424.       END IF
  425.       END SUB
  426.  
  427. '*  CarrRetKey()
  428. '*----------------------------------------------------------------------------
  429. '*  This routine handles carriage returns entered in the file
  430. '*
  431. '*
  432. * ------[ first line different ]------
  433.       SUB CarrRetKey STATIC
  434. * REPLACING old line(s) by new
  435. 1300  Index = CurrentRow + TopLine - 3
  436. * ------[ first line different ]------
  437.       IF Index >= ZMaxMsgLines THEN
  438.          EXIT SUB
  439.       END IF
  440.       IF InsertMode THEN         ' Insert a new line
  441.          FOR I = (ZMaxMsgLines - 1) TO Index + 1 STEP -1             ' DD021702
  442.             ZOutTxt$(I + 1) = ZOutTxt$(I)
  443.          NEXT I
  444.          IF LEN(ZOutTxt$(Index)) >= CurrentCol THEN
  445.             ZOutTxt$(Index + 1) = MID$(ZOutTxt$(Index), CurrentCol)
  446.             ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), CurrentCol - 1)
  447.          ELSE
  448.             ZOutTxt$(Index + 1) = BlankLine$
  449.          END IF
  450.          CALL UpdateScreen
  451.       END IF
  452.       IF ZExpertUser THEN PE = 23 _                                  'Mpl021701
  453.          Else PE = 19                                                'Mpl021701
  454.       IF CurrentRow < PE THEN                                        'Mpl021701
  455.          CALL MoveCursor(CurrentRow + 1, 1)
  456.       ELSE
  457.          CALL MoveCursor(CurrentRow, 1)
  458.          CALL UnGetChar(LineDownKey)
  459.       END IF
  460.       END SUB
  461.  
  462. '*  ChangeSubject()
  463. '*----------------------------------------------------------------------------
  464. '*  Routine to allow user to change the message subject
  465. '*
  466. '*
  467.       SUB ChangeSubject STATIC
  468.       CALL GetString("Change Subject From '" + MsgSubj$ + "' To? ", NewSubj$)
  469.       IF NewSubj$ <> "" THEN
  470.          MsgSubj$ = LEFT$(NewSubj$, 25)
  471.          CALL NameCaps(MsgSubj$)
  472.       END IF
  473.       END SUB
  474.  
  475. '*  ClearScreen()
  476. '*----------------------------------------------------------------------------
  477. '*  This routine clears the screen and moves the cursor to row 2, col 1
  478. '*
  479. '*
  480.       SUB ClearScreen STATIC
  481. * REPLACING old line(s) by new
  482. * ------[ first line different ]------
  483. 1500  IF ZExpertUser THEN PE = 23 _                                  'Mpl021701
  484.          Else PE = 19                                                'Mpl021701
  485.       FOR I = 1 TO PE                                                'Mpl021701
  486.          ZWorkAra$(I) = BlankLine$
  487.       NEXT I
  488.       CALL QuickTput(CHR$(27) + "[2J" + CHR$(27) + "[0m", 0)         ' DD021301
  489.       ZSubParm = 2
  490.       CALL Line25
  491.       ZSubParm = 0
  492.       CALL QuickTput(CHR$(27) + "[0m" + CHR$(27) + "[3;1H" + ZEmphasizeOff$, 0) ' DD021301
  493.       CurrentCol = 1
  494.       CurrentRow = 3
  495.       IsBold = DefaultBold
  496.       OldColour = DefaultColor
  497.       END SUB
  498.  
  499. '*  DeleteCurrentLine()
  500. '*----------------------------------------------------------------------------
  501. '*  This routine deletes the current line on the screen and in the array
  502. '*  ZOutTxt$, and moves the next lower line up one  It then repaints the
  503. '*  affected portion of the screen (from the deleted line down)
  504. '*
  505. '*
  506.       SUB DeleteCurrentLine (Index%) STATIC
  507. * REPLACING old line(s) by new
  508. * ------[ first line different ]------
  509. 1600  FOR I = Index% TO (ZMsgDim - 1)                                ' DD021702
  510.          ZOutTxt$(I) = ZOutTxt$(I + 1)
  511.       NEXT I
  512.       ZOutTxt$(ZMsgDim) = BlankLine$                                 ' DD021702
  513.       CALL UpdateScreen
  514.       END SUB
  515.  
  516. '*  DisplayMainMenu()
  517. '*----------------------------------------------------------------------------
  518. '*  This routine displays the main menu on the top line
  519. '*
  520. '*
  521.       SUB DisplayMainMenu STATIC
  522. * REPLACING old line(s) by new
  523. 1700  CALL MoveCursor(1, 1)
  524.       YY$ = "A)bort H)elp D)elete I)ns/ovw J)ustify "
  525.       IF ZLocalUser OR ZSysop THEN
  526.          YY$ = YY$ + "O)import R)eflow P)aint S)ave U)subject "
  527.       ELSE
  528. * ------[ first line different ]------
  529.          YY$ = YY$ + "R)eflow P)aint S)ave U)subject" + SPACE$(10)   ' DD021702
  530.       END IF
  531.       CALL ColorPrompt(YY$)
  532.       CALL PutScreen(YY$, DefaultColor, DefaultBold)
  533.       END SUB
  534.  
  535. '*  DoneWithMsg()
  536. '*----------------------------------------------------------------------------
  537. '*  This routine is called to save or abort the message
  538. '*
  539. '*
  540.       SUB DoneWithMsg (YY$) STATIC
  541. * REPLACING old line(s) by new
  542. 1810  SELECT CASE YY$
  543. * ------[ first line different ]------
  544.          CASE CHR$(83)        ' Save Message                    'S   ' DD021301
  545.             '*
  546.             '* Remove trailing blank lines from the message
  547.             '*
  548.             CALL FindEndOfMsg(EndOfMsg)
  549. '      If ZGetExtDesc Then
  550. '         Ext = 2
  551. '          Else
  552. '           Ext = 1
  553. '       End If
  554.           For I = 1 to EndOfMsg 
  555.                J = INSTR(ZOutTxt$(I), SoftSpace$)
  556.                WHILE J <> 0
  557.                   MID$(ZOutTxt$(I), J, 1) = SPACE$(1)                ' DD021301
  558.                   J = INSTR(ZOutTxt$(I), SoftSpace$)
  559.                WEND
  560.                CALL TrimTrail(ZOutTxt$(I), SPACE$(1))                ' DD021301
  561.             NEXT I
  562.             CALL FindEndOfMsg(ZLinesInMsg)
  563.             CALL EraseToEOL(1, 1)                                    'Mpl021701
  564.             CALL MoveCursor(1, 1)                                    'Mpl021701
  565.             CALL PutScreen(SPACE$(1), DefaultColor, DefaultBold)     ' DD021301
  566.             CALL ClearScreen
  567.             ZSubParm = 1
  568. * REPLACING old line(s) by new
  569. * ------[ first line different ]------
  570. 1820     CASE CHR$(65)                                          'A   ' DD021301
  571.             CALL EraseToEOL(1, 1)
  572.             YY$ = "Abort: Are You Sure (Y)es,[N]o)? "
  573.             CALL ColorPrompt(YY$)
  574.             CALL PutScreen(YY$, DefaultColor, DefaultBold)
  575.             CALL GetChar(B$)
  576.             IF ZSubParm <> 0 THEN
  577.                B$ = CHR$(89)                                    'Y   ' DD021301
  578.             END IF
  579.             CALL AllCaps(B$)                                         'RT062992
  580.             IF B$ = CHR$(89) THEN                               'Y   ' DD021301
  581.                CALL ClearScreen
  582.                ZSubParm = 2
  583.             END IF
  584.       END SELECT
  585.       END SUB
  586.  
  587. '*  EraseToEOL()
  588. '*----------------------------------------------------------------------------
  589. '*  This routine clears from a position to to the end of that line
  590. '*
  591. '*
  592.       SUB EraseToEOL (LineNumber, ColNumber) STATIC
  593. * REPLACING old line(s) by new
  594. 1900  CALL MoveCursor(LineNumber, ColNumber)
  595. * ------[ first line different ]------
  596.       CALL QuickTput(CHR$(27) + "[K", 0)                             ' DD021301
  597.       END SUB
  598.  
  599. '*  FindEndOfMsg()
  600. '*----------------------------------------------------------------------------
  601. '*  Finds the last active line in the message
  602. '*
  603. '*
  604.       SUB FindEndOfMsg (EndOfMsg) STATIC
  605.       EndOfMsg = 1
  606.       FOR I = ZMaxMsgLines TO 1 STEP -1
  607.          IF ZOutTxt$(I) <> BlankLine$ OR I <= MsgLockLines THEN
  608.             EndOfMsg = I
  609.             EXIT FOR
  610.          END IF
  611.       NEXT I
  612.       END SUB
  613.  
  614. '*  FindWrap()
  615. '*----------------------------------------------------------------------------
  616. '*  This routine finds a place in the string yy$ that could be used as a
  617. '*  place to wrap the line WhereToWrap should be the last position that
  618. '*  remains in the line, ie
  619. '*    set   currentline$ = left$(yy$,wheretowrap)
  620. '*          nextline$    = mid$ (yy$,wheretowrap+1)
  621. '*
  622. '*
  623.       SUB FindWrap (YY$, WhereToWrap) STATIC
  624. * REPLACING old line(s) by new
  625. 2100  WhereToWrap = LEN(YY$) + 1
  626.       CALL FindWord(YY$, 0, WhereToWrap)
  627.       WhereToWrap = WhereToWrap - 1
  628.       END SUB
  629.  
  630. '*  GetChar()
  631. '*----------------------------------------------------------------------------
  632. '*  This routine reads a character from the user into YY$
  633. '*
  634. '*
  635. * ------[ first line different ]------
  636.       SUB GetChar (YY$) STATIC
  637. * REPLACING old line(s) by new
  638. 2200  ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  639.       CALL Carrier
  640.       YY$ = ""
  641.       WHILE ZSubParm <> -1 AND ZSubParm <> -2 AND YY$ = ""
  642.          ZSubParm = 0
  643.          IF LEN(ZCommportStack$) > 0 THEN
  644.             YY$ = LEFT$(ZCommportStack$, 1)
  645.             ZCommportStack$ = MID$(ZCommportStack$, 2)
  646.          ELSE
  647.             IF ZLocalUser THEN
  648.                YY$ = INKEY$
  649.                IF LEN(YY$) = 2 THEN
  650.                   KeyPressed = ASC(RIGHT$(YY$, 1))
  651.                   YY$ = ""
  652.                   SELECT CASE KeyPressed
  653.                      CASE 82                  ' Insert
  654.                         KeyPressed = ToggleINSKey
  655.                      CASE 83                  ' Delete
  656.                         KeyPressed = CharDeleteKey
  657.                      CASE 71                  ' Home
  658.                         KeyPressed = HomeKey
  659.                      CASE 73                  ' PgUp
  660.                         KeyPressed = PageUpKey
  661.                      CASE 72                  ' Up Arrow
  662.                         KeyPressed = LineUpKey
  663.                      CASE 80                  ' Down Arrow
  664.                         KeyPressed = LineDownKey
  665.                      CASE 81                  ' PgDn
  666.                         KeyPressed = PageDownKey
  667.                      CASE 75                  ' Left Arrow
  668.                         KeyPressed = ColLeftKey
  669.                      CASE 77                  ' Right Arrow
  670.                         KeyPressed = ColRightKey
  671.                      CASE 115                 ' Ctrl-Left Arrow
  672.                         KeyPressed = WordLeftKey
  673.                      CASE 116                 ' Ctrl-Right Arrow
  674.                         KeyPressed = WordRightKey
  675.                      CASE 79                  ' End
  676.                         KeyPressed = EndKey
  677. * ------[ first line different ]------
  678.                      CASE 9
  679.                         KeyPressed = TabKey
  680.                      CASE ELSE
  681.                         KeyPressed = 0
  682.                   END SELECT
  683.                   IF KeyPressed <> 0 THEN
  684.                      YY$ = CHR$(KeyPressed)
  685.                   END IF
  686.                END IF
  687.             ELSE
  688.                CALL FindFKey
  689.                IF ZSubParm >= 0 THEN
  690.                   YY$ = ZKeyPressed$
  691.                   IF YY$ = "" THEN
  692.                      CALL EofComm(Char%)
  693.                      IF Char% = -1 THEN
  694.                         CALL CheckTime(ZAutoLogoff!, Remain!, 1)
  695.                         IF Remain! < 0 THEN
  696.                            CALL UpdtCalr("Sleep disconnect", 1)
  697.                            ZSubParm = -2
  698.                            ZNo = ZTrue
  699.                            ZSleepDisconnect = ZTrue
  700.                         END IF
  701.                      ELSE
  702.                         CALL Carrier
  703.                         IF ZSubParm <> -1 THEN
  704.                            ZSubParm = 0
  705.                            CALL GetCom(YY$)
  706.                         END IF
  707.                      END IF
  708.                   END IF
  709.                END IF
  710.             END IF
  711.          END IF
  712.       WEND
  713.       END SUB
  714.  
  715. '*  GetString()
  716. '*----------------------------------------------------------------------------
  717. '*  Gets a string from the user
  718. '*
  719. '*
  720.       SUB GetString (Prompt$, YY$) STATIC
  721.       YY$ = ""
  722.       CALL EraseToEOL(1, 1)
  723.       CALL PutScreen(Prompt$, DefaultColor, DefaultBold)
  724.       NewCol = CurrentCol
  725.       InitCol = NewCol
  726.       DO
  727.          CALL MoveCursor(CurrentRow, NewCol)
  728.          CALL GetChar(B$)
  729.          IF ZSubParm <> 0 THEN
  730.             B$ = CHR$(ESCKey)
  731.          END IF
  732.          KeyPressed = ASC(B$)
  733.          SELECT CASE KeyPressed
  734.             CASE BackspKey, OtherBackspKey
  735.                IF NewCol <> InitCol THEN
  736.                   CALL MoveCursor(CurrentRow, NewCol - 1)
  737.                   CALL PutScreen(SPACE$(1), DefaultColor, DefaultBold) ' DD021301
  738.                   NewCol = NewCol - 1
  739.                   YY$ = LEFT$(YY$, LEN(YY$) - 1)
  740.                END IF
  741.             CASE CarrRet
  742.                EXIT DO
  743.             CASE ESCKey
  744.                YY$ = ""
  745.                EXIT DO
  746.             CASE ELSE
  747.                YY$ = YY$ + B$
  748.                CALL PutScreen(B$, DefaultColor, DefaultBold)
  749.                NewCol = NewCol + 1
  750.          END SELECT
  751.       LOOP WHILE 1
  752.       END SUB
  753.  
  754. '*  HelpMe()
  755. '*----------------------------------------------------------------------------
  756. '*  This routine provides on-line help for the user
  757. '*
  758. '*
  759.       SUB HelpMe STATIC
  760. * REPLACING old line(s) by new
  761. 2300  CALL SaveCursor(RowSave, ColSave)
  762. * ------[ first line different ]------
  763.       ZExpertUser = ZFalse                                           'Mpl021701
  764.       CALL DisplayKeys                                               'Mpl021701
  765. '     CALL ClearScreen                                               'Mpl021701
  766. '     CALL BufFile(ZHelpPath$ + "ANSIED" + ZHelpExtension$, X)       'Mpl021701
  767. '     CALL ClearScreen                                               'Mpl021701
  768.       CALL UpdateScreen
  769.       CALL MoveCursor(RowSave, ColSave)
  770.       END SUB
  771.  
  772. '*  ImportFile()
  773. '*----------------------------------------------------------------------------
  774. '*  Imports an ASCII text file in the message
  775. '*
  776. '*
  777.       SUB ImportFile STATIC
  778.       IF ZLocalUser OR ZSysop THEN
  779.          CALL GetString("Import What File? ", FileName$)
  780.          IF FileName$ <> "" THEN
  781.             CALL FindIt(FileName$)
  782.             IF ZOK THEN
  783.                ZUserIn$(1) = FileName$
  784.                ZAnsIndex = 0
  785.                ZLastIndex = 1
  786.                CALL FindEndOfMsg(EndOfMsg)
  787.                CALL MsgImport(ZMaxMsgLines, ZRightMargin, EndOfMsg, ZOutTxt$())
  788. '              J = EndOfMsg \ 11                                     'Mpl021701
  789. '              IF EndOfMsg MOD 11 = 0 THEN                           'Mpl021701
  790. '                 J = J - 1                                          'Mpl021701
  791. '              END IF                                                'Mpl021701
  792. '              TopLine = J * 11 + 1                                  'Mpl021701
  793. '              J = EndOfMsg - TopLine                                'Mpl021701
  794. '              CALL MoveCursor(J + 5, 1)                             'Mpl021701
  795.                CALL UpdateScreen
  796.             END IF
  797.          END IF
  798.       END IF
  799.       END SUB
  800.  
  801. '*  LastParaLine()
  802. '*----------------------------------------------------------------------------
  803. '*  This routine returns ZTrue if ZOutTxt$(I) is the last line
  804. '*  in a paragraph
  805. '*
  806. '*
  807.       SUB LastParaLine (I, LastLine, Result) STATIC
  808. * REPLACING old line(s) by new
  809. 2400  Result = ZFalse
  810.       IF I = LastLine OR I >= ZMaxMsgLines THEN
  811.          Result = ZTrue
  812.       ELSE
  813.          YY$ = ZOutTxt$(I)
  814. * ------[ first line different ]------
  815.          J = INSTR(YY$, CHR$(62))                                    ' DD021301
  816.          IF J = 0 THEN
  817.             J = 6
  818.          END IF
  819.          IF J < 5 THEN
  820.             Result = ZTrue
  821.          ELSEIF YY$ = BlankLine$ THEN
  822.             Result = ZTrue
  823.          ELSE
  824.             IF ZOutTxt$(I + 1) = BlankLine$ THEN
  825.                Result = ZTrue
  826.             ELSEIF LEFT$(ZOutTxt$(I + 1), 1) = SPACE$(1) THEN        ' DD021301
  827.                Result = ZTrue
  828.             ELSE
  829.                K = INSTR(ZOutTxt$(I + 1), CHR$(62))                  ' DD021301
  830.                IF K <> 0 AND K < 5 THEN
  831.                   Result = ZTrue
  832.                END IF
  833.             END IF
  834.          END IF
  835.       END IF
  836.       END SUB
  837.  
  838. '*  MenuCommand()
  839. '*----------------------------------------------------------------------------
  840. '* This routine executes the passed main menu command
  841. '*
  842. '*
  843.       SUB MenuCommand (YY$) STATIC
  844. * REPLACING old line(s) by new
  845. 2450  ZSubParm = 0              ' v2.44a
  846.       SELECT CASE YY$
  847. * ------[ first line different ]------
  848.          CASE CHR$(72)                                          'H   ' DD021301
  849.             CALL HelpMe
  850.             CALL DisPlayKeys                                         'Pe 03/17/92
  851.          CASE CHR$(78)                                          'N   ' DD021301
  852.             CALL ClearScreen                                         'Mpl021701
  853.             CALL UpdateScreen                                        'Mpl021701
  854.          CASE CHR$(83), CHR$(65)                                'S'A ' DD021301
  855.             CALL DoneWithMsg(YY$)
  856.          CASE CHR$(80)                                          'P   ' DD021301
  857.             CALL ClearScreen
  858.             CALL DisplayKeys
  859.             CALL UpdateScreen
  860.          CASE CHR$(73)                                          'I   ' DD021301
  861.             InsertMode = NOT InsertMode
  862.          CASE CHR$(82)                                          'R   ' DD021301
  863.             CALL ReformText(ZFalse)
  864.          CASE CHR$(74)                                          'J   ' DD021301
  865.             CALL ReformText(ZTrue)
  866.          CASE CHR$(79)                                          'O   ' DD021301
  867.             CALL ImportFile
  868.          CASE CHR$(85)                                          'U   ' DD021301
  869.             CALL ChangeSubject
  870.       END SELECT
  871.       IF ZSubParm = 0 THEN
  872.          CALL EraseToEOL(1, 1)
  873.          CALL UpdateStatusLine(1)
  874.       END IF
  875.       END SUB
  876.  
  877. '*  MoveCursor()
  878. '*----------------------------------------------------------------------------
  879. '*  This routine moves the cursor to the position spec'd by newcol and
  880. '*  newrow and tries to do it with the minimum number of Ansi characters
  881. '*
  882. '*
  883.       SUB MoveCursor (NewRow, NewCol) STATIC
  884. * REPLACING old line(s) by new
  885. * ------[ first line different ]------
  886. 2500  YY$ = SPACE$(8)                                                ' DD021301
  887.       CALL MoveCurStr(CurrentRow, CurrentCol, NewRow, NewCol, YY$, YLen)
  888.       IF YLen <> 0 THEN
  889.          YY$ = LEFT$(YY$, YLen)
  890.          CALL QuickTput(YY$, 0)
  891.       END IF
  892.       ZSubParm = 0
  893.       END SUB
  894.  
  895. '*  NormalChar()
  896. '*----------------------------------------------------------------------------
  897. '*  This routine handles 'normal' characters entered into the message
  898. '*
  899. '*
  900.       SUB NormalChar (YY$) STATIC
  901.  
  902. * REPLACING old line(s) by new
  903. 2630  ELSE
  904.          '*
  905.          '* Wrap the end of the line
  906.          '*
  907.          IF NOT AtEndOfLine THEN
  908.             ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), CurrentCol - 1) + YY$ + MID$(ZOutTxt$(Index), CurrentCol)
  909.             LML = LML + 1
  910.          ELSE
  911.             MID$(ZOutTxt$(Index), CurrentCol, 1) = YY$
  912.          END IF
  913.  
  914.          CALL FindWrap(ZOutTxt$(Index), I)
  915.          IF I <= 1 THEN
  916.             I = ZRightMargin
  917.          END IF
  918.  
  919.          ZZ$ = MID$(ZOutTxt$(Index), (I + 1))
  920.          CALL TrimTrail(ZZ$, SoftSpace$)
  921.          ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), I)
  922.          '*
  923.          '* Add to the beginning of a new line
  924.          '*
  925. * ------[ first line different ]------
  926.          IF Index <= (ZMaxMsgLines - 1) THEN
  927.             Index = Index + 1
  928.          END IF
  929.  
  930.          Z = INSTR(ZOutTxt$(Index), CHR$(62))                        ' DD021301                          ' v2.44a
  931.          IF ZOutTxt$(Index) <> BlankLine$ AND (Z <= 0 OR Z > 6) AND LEN(ZOutTxt$(Index)) + LEN(ZZ$) < ZRightMargin THEN
  932.             ZOutTxt$(Index) = ZZ$ + ZOutTxt$(Index)
  933.          ELSE
  934.             FOR J = (ZMaxMsgLines - 1) TO Index STEP -1
  935.                ZOutTxt$(J + 1) = ZOutTxt$(J)
  936.             NEXT J
  937.             ZOutTxt$(Index) = ZZ$
  938.          END IF
  939.  
  940.          CALL EraseToEOL(CurrentRow, I + 1)        ' do the "easy" line
  941.          ZWorkAra$(CurrentRow) = ZOutTxt$(Index)
  942.  
  943.          CALL UpdateScreen
  944.          IF (ColSave > I) THEN
  945.             NewCol = ColSave - I + 1
  946.             IF ZExpertUser THEN PE = 23 _                            'Mpl021701
  947.                Else PE = 19                                          'Mpl021701
  948.             IF RowSave <> PE THEN                                    'Mpl021701
  949.                CALL MoveCursor(RowSave + 1, NewCol)
  950.             ELSE
  951.                CALL MoveCursor(RowSave, NewCol)
  952.                CALL UnGetChar(LineDownKey)
  953.             END IF
  954.          ELSE
  955.             CALL MoveCursor(RowSave, ColSave + 1)
  956.          END IF
  957.       END IF
  958.       END SUB
  959.  
  960. '*  PutScreen()
  961. '*----------------------------------------------------------------------------
  962. '* This routine writes YY$ to the user in the color and
  963. '* intensity specified
  964. '*
  965. '*
  966.       SUB PutScreen (YY$, Colour, Bold) STATIC
  967. * REPLACING old line(s) by new
  968. 2800  ZZ$ = ""
  969.       IF Colour <> 99 THEN
  970.          IF (Colour <> OldColour) OR (Bold <> IsBold) THEN
  971. * ------[ first line different ]------
  972.             ZZ$ = CHR$(27) + CHR$(91)                                ' DD021301
  973.             IF Bold <> IsBold THEN
  974.                IF Bold THEN
  975.                   ZZ$ = ZZ$ + CHR$(49) + CHR$(59)               '1;  ' DD021301
  976.                ELSE
  977.                   ZZ$ = ZZ$ + CHR$(48) + CHR$(59)               '0;  ' DD021301
  978.                END IF
  979.             END IF
  980.             ZZ$ = ZZ$ + MID$(STR$(Colour), 2) + CHR$(109)       'm   ' DD021301
  981.          END IF
  982.       ELSE
  983.          ZZ$ = ZEmphasizeOff$
  984.       END IF
  985.       ZOutTxt$ = ZZ$ + YY$
  986.       IF ZLocalUser THEN
  987.          CALL QuickTput(ZOutTxt$, 0)
  988.       ELSE
  989.          ZSubParm = 4
  990.          CALL Tput
  991.       END IF
  992.       ZSubParm = 0
  993.       IF INSTR(YY$, CHR$(27) + CHR$(91)) = 0 THEN                    ' DD021301
  994.          CurrentCol = CurrentCol + LEN(YY$)
  995.          IF CurrentCol > 80 THEN
  996.             CurrentCol = 0
  997.             CurrentRow = 0
  998.          END IF
  999.       ELSE
  1000.          CurrentRow = 0
  1001.          CurrentCol = 0
  1002.       END IF
  1003.       OldColour = Colour
  1004.       IsBold = Bold
  1005.       END SUB
  1006.  
  1007. '*  ReformText()
  1008. '*----------------------------------------------------------------------------
  1009. '*  This routine reflows the text to the current margins.  Optionally,
  1010. '*  it right justifies all lines by adding "soft spaces"
  1011. '*
  1012. '*
  1013.       SUB ReformText (Justify%) STATIC
  1014.  
  1015. * REPLACING old line(s) by new
  1016. 2900  DIM Places(80)
  1017.  
  1018.       CALL EraseToEOL(1, 1)
  1019.       CALL PutScreen("Reformatting... Please Wait.", WhiteFore, ZTrue)
  1020.  
  1021.       CALL FindEndOfMsg(EndOfMsg)
  1022.  
  1023.       I = MsgLockLines + 1   ' Read index
  1024.       J = MsgLockLines + 1   ' Write index
  1025.  
  1026.       '*
  1027.       '* Reflow the text to the maximum on a line
  1028.       '*
  1029.       DO WHILE I <= EndOfMsg
  1030.          '*
  1031.          '* Loop until we get a long line or an end of paragraph
  1032.          '*
  1033.          ZOutTxt$ = ""
  1034.          DO WHILE 1
  1035.             YY$ = ZOutTxt$(I)
  1036.             CALL UnString(YY$, SoftSpace$)
  1037. * ------[ first line different ]------
  1038.             IF ZOutTxt$ <> "" AND RIGHT$(ZOutTxt$, 1) <> SPACE$(1) THEN ' DD021301
  1039.                ZOutTxt$ = ZOutTxt$ + SPACE$(1)                       ' DD021301
  1040.             END IF
  1041.             ZOutTxt$ = ZOutTxt$ + YY$
  1042.             CALL LastParaLine(I, EndOfMsg, EndOfPara)
  1043.             I = I + 1
  1044.             IF LEN(ZOutTxt$) > ZRightMargin THEN
  1045.                '*
  1046.                '* Wrap the long line
  1047.                '*
  1048.                CALL FindWrap(LEFT$(ZOutTxt$, ZRightMargin + 1), K)
  1049.                IF K <= 1 THEN
  1050.                   K = ZRightMargin
  1051.                END IF
  1052.                ZOutTxt$(J) = LEFT$(ZOutTxt$, K)
  1053.                IF EndOfPara THEN
  1054.                   '*
  1055.                   '* Go to the next paragraph
  1056.                   '*
  1057.                   J = J + 1
  1058.                   ZOutTxt$(J) = MID$(ZOutTxt$, K + 1)
  1059.                ELSE
  1060.                   '*
  1061.                   '* Keep the remaining part of the line and process
  1062.                   '* it on the next pass
  1063.                   '*
  1064.                   I = I - 1
  1065.                   ZOutTxt$(I) = MID$(ZOutTxt$, K + 1)
  1066.                END IF
  1067.                J = J + 1
  1068.                EXIT DO
  1069.             ELSEIF EndOfPara THEN
  1070.                ZOutTxt$(J) = ZOutTxt$
  1071.                J = J + 1
  1072.                EXIT DO
  1073.             END IF
  1074.          LOOP
  1075.       LOOP
  1076.  
  1077.       FOR I = J TO ZMsgDim                                           ' DD021702
  1078.          ZOutTxt$(I) = BlankLine$
  1079.       NEXT
  1080.  
  1081.       EndOfMsg = J - 1
  1082.  
  1083.       '*
  1084.       '* Space out the text on each line
  1085.       '*
  1086.       IF Justify% THEN
  1087.          FOR I = MsgLockLines + 1 TO EndOfMsg
  1088.             CALL LastParaLine(I, EndOfMsg, EndOfPara)
  1089.             IF NOT EndOfPara THEN
  1090.                '*
  1091.                '* Space out the line
  1092.                '*
  1093.                ZOutTxt$ = ZOutTxt$(I)
  1094.                CALL TrimTrail(ZOutTxt$, SPACE$(1))                   ' DD021301
  1095.                TxtLen = LEN(ZOutTxt$)
  1096.                SpacesToAdd = ZRightMargin - TxtLen
  1097.                IF SpacesToAdd > 0 THEN
  1098.                   '*
  1099.                   '* Skip leading spaces on the line
  1100.                   '*
  1101.                   Place = 1
  1102.                   IF LEFT$(ZOutTxt$, 1) = SPACE$(1) THEN             ' DD021301
  1103.                      CALL FindWord(ZOutTxt$, 1, Place)
  1104.                   END IF
  1105.                   '*
  1106.                   '* Find all of the possible places to space out the line
  1107.                   '*
  1108.                   NumPlaces = 0
  1109.                   DO WHILE 1
  1110.                      CALL FindWord(ZOutTxt$, 1, Place)
  1111.                      IF Place < TxtLen THEN
  1112.                         NumPlaces = NumPlaces + 1
  1113.                         Places(NumPlaces) = Place
  1114.                      ELSE
  1115.                         EXIT DO
  1116.                      END IF
  1117.                   LOOP
  1118.                   '*
  1119.                   '* Fill in available places with soft spaces
  1120.                   '*
  1121.                   IF NumPlaces <> 0 THEN
  1122.                      ExtraPlaces = (SpacesToAdd MOD NumPlaces)
  1123.                      LeftExtra = ExtraPlaces \ 2
  1124.                      RightExtra = ExtraPlaces - LeftExtra
  1125.                      FOR J = NumPlaces TO 1 STEP -1
  1126.                         SpacesThisPlace = SpacesToAdd \ NumPlaces
  1127.                         IF J <= LeftExtra OR J > NumPlaces - RightExtra THEN
  1128.                            SpacesThisPlace = SpacesThisPlace + 1
  1129.                         END IF
  1130.                         IF SpacesThisPlace <> 0 THEN
  1131.                            ZOutTxt$ = LEFT$(ZOutTxt$, Places(J) - 1) + STRING$(SpacesThisPlace, SoftSpace$) + MID$(ZOutTxt$, Places(J))
  1132.                         END IF
  1133.                      NEXT J
  1134.                   END IF
  1135.                END IF
  1136.                ZOutTxt$(I) = ZOutTxt$
  1137.             END IF
  1138.          NEXT I
  1139.       END IF
  1140.  
  1141.       CALL UpdateScreen
  1142.  
  1143.       END SUB
  1144.  
  1145. '*  SaveCursor()
  1146. '*----------------------------------------------------------------------------
  1147. '*  This routine saves the current cursor position
  1148. '*
  1149. '*
  1150.       SUB SaveCursor (Row%, Col%) STATIC
  1151.       Row% = CurrentRow
  1152.       Col% = CurrentCol
  1153.       END SUB
  1154.  
  1155. '*  UnGetChar()
  1156. '*----------------------------------------------------------------------------
  1157. '*   Puts a key in the beginning of the keyboard buffer
  1158. '*
  1159. '*
  1160.       SUB UnGetChar (X) STATIC
  1161.       ZCommportStack$ = CHR$(X) + ZCommportStack$
  1162.       END SUB
  1163.  
  1164. '*  UnString()
  1165. '*----------------------------------------------------------------------------
  1166. '*  Removes one string from another
  1167. '*
  1168. '*
  1169.       SUB UnString (YY$, BadString$)  STATIC
  1170.       I = INSTR(YY$, BadString$)
  1171.       WHILE I <> 0
  1172.          YY$ = LEFT$(YY$, I - 1) + MID$(YY$, I + LEN(BadString$))
  1173.          I = INSTR(YY$, BadString$)
  1174.       WEND
  1175.       END SUB
  1176.  
  1177. '*  UpdateScreen()
  1178. '*----------------------------------------------------------------------------
  1179. '*  This is one of the most important routines  It compares the arrays
  1180. '*  ZOutTxt$ and ZWorkAra$ and only sends the user the DIFFERENCE between the
  1181. '*  two within the viewing area  In this way all processing can be done on
  1182. '*  ZOutTxt$ and then the screen is updated to reflect the changes. After the
  1183. '*  users screen is updated, ZWorkAra$ is changed to reflect what should be
  1184. '*  on the users' screen The cursor is restored to its original position
  1185. '*
  1186. '*
  1187.       SUB UpdateScreen  STATIC
  1188. * REPLACING old line(s) by new
  1189. 3100  CALL SaveCursor(RowSave, ColSave)
  1190. * ------[ first line different ]------
  1191.       IF ZExpertUser THEN PE = 23 _                                  'Mpl021701
  1192.          Else PE = 19                                                'Mpl021701
  1193.       FOR I = 3 TO PE AND Index < ZMsgDim                            ' DD021702
  1194.          Index = I + TopLine - 3
  1195.          ScreenLine$ = ZWorkAra$(I)
  1196.          IF Index >= ZMsgDim THEN
  1197.             MessageLine$ = ZOutTxt$(ZMsgDim)
  1198.          ELSE
  1199.             MessageLine$ = ZOutTxt$(Index)
  1200.          ENDIF
  1201.          LML = LEN(MessageLine$)
  1202.          IF Index = ZMaxMsgLines + 1 THEN
  1203.             CALL EraseToEOL(I, 1)
  1204.             CALL PutScreen("[* End of Message *]", CyanFore, ZTrue)  ' DD021702
  1205.             ZWorkAra$(I) = CHR$(EndKey)
  1206.          ELSEIF Index > ZMaxMsgLines + 1 THEN
  1207.             IF ScreenLine$ <> BlankLine$ THEN
  1208.                CALL EraseToEOL(I, 1)
  1209.                ZWorkAra$(I) = BlankLine$
  1210.             END IF
  1211.          ELSEIF MessageLine$ = ScreenLine$ THEN
  1212.             '*
  1213.             '* Screen = What's in message buffer
  1214.             '*
  1215.          ELSEIF MessageLine$ = BlankLine$ OR MessageLine$ = SPACE$(LML) THEN
  1216.             CALL EraseToEOL(I, 1)
  1217.             ZWorkAra$(I) = MessageLine$
  1218.          ELSE
  1219.             CALL MoveCursor(I, 1)
  1220.             YY$ = MessageLine$
  1221.             IF BlockDelActive AND CurrentRow <= RowSave THEN         ' DD021702
  1222.                CALL PutScreen(YY$, RedFore,ZFalse)                   ' DD021702
  1223.             ELSE                                                     ' DD021702
  1224.                CALL PutScreen(YY$, YellowFore, ZTrue)                ' DD021702
  1225.             END IF                                                   ' DD021702
  1226.             CALL EraseToEOL(CurrentRow, CurrentCol)
  1227.             ZWorkAra$(I) = ZOutTxt$(Index)
  1228.          END IF
  1229.       NEXT I
  1230.       CALL MoveCursor(RowSave, ColSave)
  1231.       END SUB
  1232.  
  1233. '*  UpdateStatusLine()
  1234. '*-----------------------------------------------------------------------------
  1235. '*  Rewrites the status line on screen line(s) 1 and 2
  1236. '*
  1237. '*    Input:  How% = 1   - Rewrite both lines
  1238. '*            How% = 2   - Just rewrite top line
  1239. '*
  1240.       SUB UpdateStatusLine (How%)  STATIC
  1241. * REPLACING old line(s) by new
  1242. * ------[ first line different ]------
  1243. 3200  YY$ = "ANSIED" + SPACE$(1) + Version$ + SPACE$(1) + "by Tom Collins" + SPACE$(23) + "* Press ESC Twice for Menu *"
  1244.       YY$ = YY$ + SPACE$(79 - LEN(YY$))
  1245.       CALL MoveCursor(1, 1)
  1246.       CALL PutScreen(YY$, BlueFore, ZTrue)
  1247. * REPLACING old line(s) by new
  1248. 3210  IF How% = 1 THEN
  1249. * ------[ first line different ]------
  1250.          YY$ = CHR$(205) + " To: " + MsgTo$ + SPACE$(1) + CHR$(205) + " Re: " + MsgSubj$ + SPACE$(1) + CHR$(205) ' DD021702
  1251.          YY$ = YY$ + STRING$(79 - LEN(YY$), CHR$(205))
  1252.          IF InsertMode THEN
  1253.             MID$(YY$, 74) = " Ins "
  1254.          ELSE
  1255.             MID$(YY$, 74) = " Ovw "
  1256.          END IF
  1257.          I = 1
  1258.          CALL MoveCursor(2, I)
  1259.          CALL PutScreen(YY$, RedFore, ZTrue)
  1260.       END IF
  1261.       END SUB
  1262.  
  1263. * INSERTING new line(s)
  1264. 3220 SUB DisplayKeys  STATIC                                          'Mpl021701
  1265.      IF ZExpertUser THEN EXIT SUB                                    'Mpl021701
  1266.      CALL MoveCursor(20,1)
  1267.      YY$ = STRING$(79,CHR$(205))
  1268.      MID$ (YY$,30) = " ANSIED QuickKeys Menu "
  1269.      CALL PutScreen(YY$,RedFore,ZTrue)                               ' DD021702
  1270.      CALL MoveCursor(21,1)
  1271.      CALL PutScreen ("^E Up  ^X Down    ^D Right    ^S Left    ^R PgUp   ^C PgDn ^W Home  ^Z End",YellowFore, ZTrue) ' DD021702
  1272.      CALL MoveCursor(22,1)
  1273.      CALL PutScreen ("^G Del ^V Ins/Ovw ^B ReFormat ^P RePaint ^O ReFlow ^N Help On  ^J Help Off",YellowFore, ZTrue) ' DD021702
  1274.      CALL MoveCursor(23,1)
  1275.      CALL PutScreen ("^A Word Left ^F Word Right ^Y Del Line ^T Del Word ^K Top Menu",YellowFore, ZTrue) ' DD021702
  1276.      END SUB
  1277.